package com.gw.musicbox;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLUtils;
import android.opengl.GLSurfaceView.Renderer;
import android.util.Log;

public class gameplay implements Renderer
{
	
	TextureMgr m_TextureMgr;
	Context m_context;
	hud m_hud;
	
	public gameplay(Context context)
	{
		m_context = context;	
	}
	
	private void InitObject(GL10 gl)
	{
		m_TextureMgr = new TextureMgr(gl, m_context);
		m_hud = new hud(m_TextureMgr);
		

	}
	
	@Override
	public void onDrawFrame(GL10 gl)
	{
		// TODO Auto-generated method stub
		m_hud.draw(gl);
			Log.d("TAG","=======");	
		

	}

	@Override
	public void onSurfaceChanged(GL10 gl, int arg1, int arg2)
	{
		InitObject(gl);
		// TODO Auto-generated method stub
		gl.glViewport(0,0,480,800);
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();
		gl.glOrthof(0.0f, 480.0f, 0.0f, 800.0f, -1.0f, 1.0f);
		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
	}

	@Override
	public void onSurfaceCreated(GL10 gl, EGLConfig arg1)
	{
		// TODO Auto-generated method stub
		gl.glEnable(GL10.GL_TEXTURE_2D);
		gl.glShadeModel(GL10.GL_SMOOTH); // Enable Smooth Shading
		gl.glEnable(GL10.GL_BLEND);
		gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
		gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
		
		//
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();
		gl.glOrthof(0.0f, 480.0f, 0.0f, 800.0f, -1.0f, 1.0f);
		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
		//

	}

}
